<!-- 案场破底价审核 -->
<template>
  <div class='base_price'>
    <Button type="primary" class="operate-btn"> <a
      href="https://images.tospurfang.com/doc/%E7%A0%B4%E5%BA%95%E4%BB%B7%E5%AE%A1%E6%A0%B8%E6%93%8D%E4%BD%9C%E6%8C%87%E5%BC%95.pdf"
      style="color:#fff;" target="_blank">查看操作指引</a>
    </Button>
    <Tabs v-model="curState" type="card" :animated="false" @on-click="onChangeTab">
      <TabPane label="待审核" name="0"></TabPane>
      <TabPane label="已通过" name="1"></TabPane>
      <TabPane label="已驳回" name="2"></TabPane>
    </Tabs>
    <dt-grid ref="table" page :onFetch='onFetch' />
    <detail-modal ref="detailModal" :isCompanyBase=true @success='success' />
  </div>
</template>

<script>
  import auditMgr from '@/biz/flowApproval/processAudit.js'
  import column from './opt/column'
  import detailModal from './components//detailModal'
  export default {
    components: { detailModal },
    data() {
      return {
        curState: '0',
        oldState: '0',
        searchInfo: {
          state: '',
          productId: '',
          roomName: '',
          housesId: this.$dt.buildInfo().housesId,
        },
        instanceId: '',
      }
    },
    methods: {
      onChangeTab(val) {
        if (val == this.oldState) return false
        this.oldState = val
        this.init()
      },
      onFetch(data) {
        return auditMgr.list({
          ...data,
          auditType: 9,
          housesId: this.$dt.buildInfo().housesId,
          buttonType: this.curState,
          instanceId: this.instanceId,
        }).then(res => {
          res && res.list.forEach(item => {
            item = Object.assign(item, item.auditData)
          })
          return res
        })
      },
      viewFun(data) {
        data.title = '查看'
        data.flag = 'check'
        this.$refs.detailModal.show(data)
      },
      auditFun(data) {
        console.log(data)
        data.title = '审核'
        data.flag = 'audit'
        this.$refs.detailModal.show(data)
      },
      success() {
        this.$refs.table.fetch()
      },
      init() {
        this.$refs.table.init(this, new column(this))
        this.$refs.table.fetch()
      },
    },
    mounted() {
      this.instanceId = this.$route.params.instanceId ? this.$route.params.instanceId : ''
      this.init()
    },
  }
</script>
<style lang='scss' scoped>
  .base_price {
    position: relative;
    padding: 20px;
    .operate-btn{
      position: absolute;
      right: 20px;
      top: 10px;
      z-index: 9999;
    }

  }
</style>